#ifndef BINARYOUTSTREAMHH
#define BINARYOUTSTREAMHH
#include "typedefs.hh"

namespace licada
{
    class IBinaryOutStream
    {
    public:
	virtual ~IBinaryOutStream(){}
	virtual void operator<<( licada::uint8 val ) = 0;
	virtual void operator<<( const licada::TDataVector& data ) = 0;
    };

    class VectorBinaryOutStream : public IBinaryOutStream
    {
    protected:
	licada::TDataVector* data;
    public:
	VectorBinaryOutStream(): data(NULL){}
	virtual void setup( licada::TDataVector* _data) { data = _data; }
	virtual void operator<<( licada::uint8 val ) { data->push_back( val ); }
	virtual void operator<<( const licada::TDataVector& data ) {
	    write( (const licada::uint8*)&(*data.begin()), data.size());
	}
    protected:
	void write( const licada::uint8* src, licada::uint32 len ) {
	    for ( ; len; --len, ++src )
		data->push_back(*src);
	}
    };
}
#endif
